package com.shuw.com.beingfortextproject.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.shuw.com.beingfortextproject.R;
import com.shuw.com.beingfortextproject.base.BaseActivity;
import com.shuw.com.beingfortextproject.utils.RxBus;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.refactor.lib.colordialog.PromptDialog;
import rx.Observable;

public class DialogActivity extends BaseActivity {

	@BindView(R.id.center_title)
	TextView centerTitle;
	@BindView(R.id.toolbar)
	Toolbar toolbar;
	@BindView(R.id.background)
	LinearLayout background;
//	@BindView(R.id.tab)
//	TableLayout tab;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_dialog);

		ButterKnife.bind(this);
		initView();
	}

	private void initView() {
//		registerRxBus();
		centerTitle.setText("对话框测试");
		setToolbar(toolbar);

//		tab.
	}

	private RxBus rxBus = RxBus.getDefault();

	// 根据传递的eventType类型返回特定类型(eventType)的被观察者
	private Observable registerRxBus() {
		return rxBus.bus.ofType(Object.class);
	}

	@OnClick({R.id.btn1, R.id.btn2, R.id.btn3})
	public void onClick(View view) {
		switch (view.getId()) {
			case R.id.btn1:
				showDialog1();
				break;
			case R.id.btn2:
//				sendEvent();
				break;
			case R.id.btn3:
				startViewPager();
				break;
		}
	}

	private void startViewPager() {
		startActivity(new Intent(this,ViewPagerActivity.class));
	}

	private static final String TAG ="DialogActivity";
	private void getBackgroundColor() {
		Log.d(TAG,"the color is --->"+background.getSolidColor());
	}

	private void sendEvent() {
//		rxBus.bus.onNext();
	}

	private void showDialog1() {
		new PromptDialog(this)
				.setDialogType(PromptDialog.DIALOG_TYPE_SUCCESS)
				.setAnimationEnable(true)
				.setTitleText("titleText显示在这里")
				.setContentText("contentText显示在这里")
				.setPositiveListener(promptDialog -> {
					promptDialog.dismiss();
				})
				.show();
	}


}
